﻿// <copyright file="SRDescriptionAttribute.cs" company="DotNetLib">
//
// .netlib: http://www.codeplex.com/DotNetLib
//
// This code is released under the New BSD License.
// A copy of this license is available at:
// http://www.codeplex.com/DotNetLib/license
//
// </copyright>

namespace DotNetLib.Internal
{
  using System;
  using System.ComponentModel;
  using DotNetLib.Properties;

  /// <summary>
  /// Provides a localizable way to get designer descriptions.
  /// </summary>
  [AttributeUsage(AttributeTargets.All)]
  internal sealed class SRDescriptionAttribute : DescriptionAttribute
  {
    private bool replaced;

    public SRDescriptionAttribute(string description)
      : base(description)
    {
    }

    public override string Description
    {
      get
      {
        if (!this.replaced)
        {
          this.replaced = true;
          this.DescriptionValue = Resources.ResourceManager.GetString(base.Description);
        }

        return base.Description;
      }
    }
  }
}
